﻿// #include <benchmark/benchmark.h>

// #include <learn/math/line_search.h>

// using namespace xi;
// using namespace xi::math;

// namespace
// {

// double parabola(VectorXd x)
// {
//     return x[0] * x[0] + x[1] * x[1];
// }

// VectorXd derivative_parabola(VectorXd x)
// {
//     return {2 * x[0], 2 * x[1]};
// }

// MatrixXd hessian_parabola(VectorXd x)
// {
//     MatrixXd H(2, 2);
//     H(0, 0) = 2;
//     H(0, 1) = 0;
//     H(1, 0) = 0;
//     H(1, 1) = 2;
//     return H;
// }

// double rosenbrock(VectorXd x)
// {
//     return (1 - x[0]) * (1 - x[0]) + 100 * (x[1] - x[0] * x[0]) * (x[1] - x[0] * x[0]);
// }

// VectorXd derivative_rosenbrock(VectorXd x)
// {
//     return {2 * (1 - x[0]) - 400 * x[0] * (x[1] - x[0] * x[0]), 200 * (x[1] - x[0] * x[0])};
// }

// MatrixXd hessian_rosenbrock(VectorXd x)
// {
//     MatrixXd H(2, 2);
//     H(0, 0) = 1200 * x[0] * x[0] - 400 * x[1] + 2;
//     H(0, 1) = -400 * x[0];
//     H(1, 0) = -400 * x[0];
//     H(1, 1) = 200;
//     return H;
// }

// double beale(VectorXd x)
// {
//     return (1.5 - x[0] + x[0] * x[0]) * (1.5 - x[1] + x[1] * x[1]) +
//            (2.25 - x[0] + x[0] * x[0] * x[0]) * (2.25 - x[1] + x[1] * x[1] * x[1]) +
//            (2.625 - x[0] + x[0] * x[0]) * (2.625 - x[1] + x[1] * x[1] * x[1] * x[1]);
// }

// VectorXd derivative_beale(VectorXd x)
// {
//     return {4 * x[0] * x[0] - 2.5 + 2 * x[0] * x[0] * x[0], 4 * x[1] * x[1] - 2.5 + 2 * x[1] * x[1] * x[1]};
// }

// void bench_golden_section_line_search(benchmark::State &state)
// {
//     for (auto _ : state)
//         golden_section_line_search(parabola, VectorXd{-1, -1}, VectorXd{1, 1}, 1e-10);
// }
// BENCHMARK(bench_golden_section_line_search);

// void bench_armijo_goldstein_line_search(benchmark::State &state)
// {
//     for (auto _ : state)
//         armijo_goldstein_line_search(parabola, derivative_parabola, VectorXd{-1, -1}, VectorXd{1, 1}, 1e-10);
// }
// BENCHMARK(bench_armijo_goldstein_line_search);

// void bench_wolfe_powell_line_search(benchmark::State &state)
// {
//     for (auto _ : state)
//         wolfe_powell_line_search(parabola, derivative_parabola, VectorXd{-1, -1}, VectorXd{1, 1}, 1e-10);
// }
// BENCHMARK(bench_wolfe_powell_line_search);

// void bench_backtracking_line_search(benchmark::State &state)
// {
//     for (auto _ : state)
//         backtracking_line_search(parabola, derivative_parabola, VectorXd{-1, -1}, VectorXd{1, 1}, 1e-10);
// }
// BENCHMARK(bench_backtracking_line_search);

// } // namespace
